//
//  NSKeyValueCodingAdditions.java
//  WOGroovy
//

package groovy.lang.webobjects.categories;

import com.webobjects.foundation.*;

public class NSKeyValueCodingAdditions {

    //
    // accessing
    //
    
    public static Object get(NSKeyValueCoding self, String key) {
        return self.valueForKey(key);
    };
    
    public static void set(NSKeyValueCoding self, String key, Object value) {
        self.takeValueForKey(value, key);
    }
    
    public static Object valueForKey(Object self, String key) {
    	return NSKeyValueCoding.Utility.valueForKey(self, key);
    }
    
    public static void takeValueForKey(Object self, Object value, String key) {
    	NSKeyValueCoding.Utility.takeValueForKey(self, value, key);
    }
    
    // Maybe calling this class NSKeyValueCodingAdditions wasn't such a clever idea. Doh!
    public static Object valueForKeyPath(Object self, String keyPath) {
    	if (self instanceof NSKeyValueCodingAdditions) {
    		return ((com.webobjects.foundation.NSKeyValueCodingAdditions)self).valueForKeyPath(keyPath);
    	}
    	return com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation.valueForKeyPath(
    			self, keyPath);
    }
    	
    public static void takeValueForKeyPath(Object self, Object value, String keyPath) {
    	if (self instanceof NSKeyValueCodingAdditions) {
    		((com.webobjects.foundation.NSKeyValueCodingAdditions)self).takeValueForKeyPath(value, keyPath);
    	} else {
    		com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation.takeValueForKeyPath(
    				self, value, keyPath);
    	}
    }
}
